<template>
    <div>
        <div v-show="!ifShowDetail">
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#gdzc" role="tab" data-toggle="tab">固定资产</a></li>
                <li role="presentation"><a href="#qgwrk" role="tab" data-toggle="tab">请购未入库</a></li>
                <li role="presentation"><a href="#rkwsh" role="tab" data-toggle="tab" @click="getRkwclTable">入库未验收</a></li>
            
            </ul>
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="gdzc">
                    <div class="form-inline" style=" float:left; padding: 5px 0;">
                        <span>部门:</span>
                        <select id="assets_search_dept" class="form-control"></select>
                        <select id="assets_search_ftype" class="form-control">
                            <option value="">固定资产类型</option>
                            <option value="生产设施">生产设施</option>
                            <option value="IT设施">IT设施</option>
                            <option value="储运设施">储运设施</option>
                            <option value="厂房设施">厂房设施</option>
                            <option value="后勤设施">后勤设施</option>
                            <option value="办公设施">办公设施</option>
                            <option value="计量器具">计量器具</option>
                            <option value="工厂设施">工厂设施</option>
                            <option value="实验设施">实验设施</option>
                        </select>
                        <input type="text" class="form-control" id="extra" placeholder="请输入关键字...">
                        <a class="btn btn-theme" @click="getAssetsByCondition">查询</a>
                        <a class="btn btn-theme " @click="showPrintMOdal">打印财产卡</a>
                        <a class="btn btn-theme " @click="postToExcel">输出到Excel</a>
                        <a class="btn btn-theme " @click="ruKu">添加固定资产</a>
                    </div>
                    <table class="table" style="clear: both" id="gdzcTable"></table>
                    <div class="modal fade" id="print_submit_modal">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                    <h4 class="modal-title">打印确认</h4>
                                </div>
                                <div class="modal-body">
                                    <p>确定要打印？</p>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <button type="button" class="btn btn-primary" @click="printCards">确定</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div role="tabpanel" class="tab-pane" style="padding-top: 5px;" id="qgwrk">
                    <table id="qgwrkTable" class="table"></table>
                          
                </div>
                <div role="tabpanel" class="tab-pane" style="padding-top: 5px;" id="rkwsh">
                     <table id="rkwysTable" class="table"></table>
                </div>
              
            </div>
            <div class="modal fade" id="gdzc_add_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
                            <div class="modal-dialog modal-lg" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title" id="exampleModalLabel">固定资产入库</h4>
                                    </div>
                                    <div class="modal-body">
                                        <form>
                                            <div class="form-group col-md-3">
                                                <label for="fmbarcode" class="control-label">资产编码</label>
                                                <input type="text" class="form-control input-sm" name="fmbarcode" id="fmbarcode">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmtype" class="control-label">资产类型</label>
                                                <select type="text" class="form-control input-sm" name="fmtype" id="fmtype">
                                                <option value="生产设施">生产设施</option>
                                                    <option value="储运设施">储运设施</option>
                                                    <option value="实验设施">实验设施</option>
                                                    <option value="厂房设施">厂房设施</option>
                                                    <option value="后勤设施">后勤设施</option>
                                                    <option value="办公设施">办公设施</option>
                                                    <option value="计量器具">计量器具</option>
                                                    <option value="工厂设施">工厂设施</option>
                                                </select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmname" class="control-label">名称</label>
                                                <input type="text" class="form-control input-sm" name="fmname" id="fmname">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmmodel" class="control-label">型号</label>
                                                <input type="text" class="form-control input-sm" name="fmmodel" id="fmmodel">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmunitid" class="control-label">单位</label>
                                                <select type="text" class="form-control input-sm" name="fmunitid" id="fmunitid"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmvalue" class="control-label">价值</label>
                                                <input type="text" class="form-control input-sm" name="fmvalue" id="fmvalue">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmsavedeptid" class="control-label">保管部门</label>
                                                <select type="text" class="form-control input-sm" name="fmsavedeptid" id="fmsavedeptid"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmsaveuserid" class="control-label">保管人</label>
                                                <select type="text" class="form-control input-sm" name="fmsaveuserid" id="fmsaveuserid"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmusedeptid" class="control-label">使用部门</label>
                                                <select type="text" class="form-control input-sm" name="fmusedeptid" id="fmusedeptid"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmuseuserid" class="control-label">使用人</label>
                                                <select type="text" class="form-control input-sm" name="fmuseuserid" id="fmuseuserid"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmwh" class="control-label">仓库号</label>
                                                <select type="text" class="form-control input-sm" name="fmwh" id="fmwh"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmlocation" class="control-label">库位号</label>
                                                <select type="text" class="form-control input-sm" name="fmlocation" id="fmlocation"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fminway" class="control-label">获得方式</label>
                                                <input type="text" class="form-control input-sm" name="fminway" id="fminway">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmindate" class="control-label">获取日期</label>
                                                <input type="date" class="form-control input-sm" name="fmindate" id="fmindate">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmsupplierid" class="control-label">供应商</label>
                                                <select type="text" class="form-control input-sm" name="fmsupplierid" id="fmsupplierid"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmmanuid" class="control-label">生产商</label>
                                                <select type="text" class="form-control input-sm" name="fmmanuid" id="fmmanuid"></select>
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmmanudate" class="control-label">生产日期</label>
                                                <input type="date" class="form-control input-sm" name="fmmanudate" id="fmmanudate">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmusemonths" class="control-label">可使用月数</label>
                                                <input type="text" class="form-control input-sm" name="fmusemonths" id="fmusemonths">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="fmnotes" class="control-label">备注</label>
                                                <input type="text" class="form-control input-sm" name="fmnotes" id="fmnotes">
                                            </div>
                                            <div class="form-group col-md-3">
                                                <label for="minvoice" class="control-label">发票信息</label>
                                                <input type="text" class="form-control " name="mincoice" id="minvoice">
                                            </div>

                                        </form>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                        <button type="button" class="btn btn-primary" @click="addSubmit">提交</button>
                                    </div>
                                </div>
                            </div>
                </div>
        </div>
        <div v-show="ifShowDetail">
                 <section id="assetsdetail" class="container-fluid">

                <div>
                    <a style="margin-bottom:10px;" class="btn btn-theme pull-left" @click="back"><i class="fa fa-reply"></i> 返回资产列表</a>
                    <!--<a class="btn btn-success" id="checkpass" style="float:right; margin-bottom:10px;" >验收通过</a>-->
                </div>
                <div class="row" style=" clear:both; border-radius:5px;background-color:#fbfbfb">
                    <div id="parent_div" class="form-group col-md-3">
                        <label for="fparentidno" class="control-label">父类编号</label>
                        <input type="text" class="form-control " name="fparentidno" id="fparentidno">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fbarcode" class="control-label">资产编码</label>
                        <input type="text" class="form-control " name="fbarcode" id="fbarcode">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="ftype" class="control-label">资产类型</label>
                        <select type="text" class="form-control " name="ftype" id="ftype">
                            <option value="生产设施">生产设施</option>
                            <option value="IT设施">IT设施</option>
                            <option value="储运设施">储运设施</option>
                            <option value="实验设施">实验设施</option>
                            <option value="厂房设施">厂房设施</option>
                            <option value="后勤设施">后勤设施</option>
                            <option value="办公设施">办公设施</option>
                            <option value="计量器具">计量器具</option>
                            <option value="工厂设施">工厂设施</option>
                        </select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fname" class="control-label">名称</label>
                        <input type="text" class="form-control " name="fname" id="fname">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fmodel" class="control-label">型号</label>
                        <input type="text" class="form-control " name="fmodel" id="fmodel">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="funitid" class="control-label">单位</label>
                        <select type="text" class="form-control " name="funitid" id="funitid">

                        </select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fvalue" class="control-label">价值</label>
                        <input type="text" class="form-control " name="fvalue" id="fvalue">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fsavedeptid" class="control-label">保管部门</label>
                        <select type="text" class="form-control " name="fsavedeptid" id="fsavedeptid"></select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fsaveuserid" class="control-label">保管人</label>
                        <select type="text" class="form-control " name="fsaveuserid" id="fsaveuserid"></select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fusedeptid" class="control-label">使用部门</label>
                        <select type="text" class="form-control " name="fusedeptid" id="fusedeptid"></select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fuseuserid" class="control-label">使用人</label>
                        <select type="text" class="form-control " name="fuseuserid" id="fuseuserid"></select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fwh" class="control-label">放置地类型</label>
                        <select type="text" class="form-control " @click="getWh" name="fwh" id="fwh"></select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="flocation" class="control-label">放置地</label>
                        <select type="text" class="form-control " name="flocation" id="flocation"></select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="finway" class="control-label">获得方式</label>
                        <input type="text" class="form-control " name="finway" id="finway">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="findate" class="control-label">获取日期</label>
                        <input type="date" class="form-control " name="findate" id="findate">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fsupplierid" class="control-label">供应商号</label>
                        <select type="text" class="form-control " name="fsupplierid" id="fsupplierid"></select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fmanuid" class="control-label">生产商</label>
                        <select type="text" class="form-control " name="fmanuid" id="fmanuid"></select>
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fmanudate" class="control-label">生产日期</label>
                        <input type="date" class="form-control " name="fmanudate" id="fmanudate">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fusemonths" class="control-label">可使用月数</label>
                        <input type="text" class="form-control " name="fusemonths" id="fusemonths">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fnotes" class="control-label">备注</label>
                        <input type="text" class="form-control " name="fnotes" id="fnotes">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fyn1" class="control-label">是否验收</label>
                        <input type="text" class="form-control " readonly name="fyn1" id="fyn1">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fynuser1" class="control-label">验收人</label>
                        <input type="text" class="form-control " readonly name="fynuser1" id="fynuser1">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="fyndate1" class="control-label">验收日期</label>
                        <input type="text" class="form-control " readonly name="fyndate1" id="fyndate1">
                    </div>
                    <div class="form-group col-md-3 hidden">
                        <label for="fyn2" class="control-label">fyn2</label>
                        <input type="text" class="form-control " name="fyn2" id="fyn2">
                    </div>
                    <div class="form-group col-md-3 hidden ">
                        <label for="fynuser2" class="control-label">fynuser2</label>
                        <input type="text" class="form-control " name="fynuser2" id="fynuser2">
                    </div>
                    <div class="form-group col-md-3 hidden">
                        <label for="fyndate2" class="control-label">fyndate2</label>
                        <input type="text" class="form-control " name="fyndate2" id="fyndate2">
                    </div>
                    <div class="form-group col-md-3">
                        <label for="invoice" class="control-label">发票信息</label>
                        <input type="text" class="form-control " name="incoice" id="invoice">
                    </div>
                </div>
                <div class="pull-right" style="padding:5px;">
                    <a class="btn btn-theme btn-sm" @click="back">取消</a>
                    <a class="btn btn-theme btn-sm" >保存</a>
                </div>
            </section>

            <section class="container-fluid" id="parts_container" style="padding:0;">
                <div class="row" style="margin:0 auto;  padding-top:5px;">
                    <div class="col-md-6" style="padding-left:0;">
                        <label>变更信息</label>
                        <div style="min-height:150px; max-height:300px; overflow-y:scroll;margin-top:10px;border-radius:5px;background-color:#fbfbfb ">
                            <table id="assets_log" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>变更说明</th>
                                        <th>操作人</th>
                                        <th>操作日期</th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="col-md-6" style="padding-right:0">
                        <label>配件列表</label>
                        <a class="btn btn-theme btn-sm" @click="deleteParts" id="parts_drop" style="float:right; margin-right:5px;" >删除配件</a>
                        <a class="btn btn-theme btn-sm" @click="showModifyPartsModal" id="parts_modify" style="float:right; margin-right:5px;">编辑配件</a>
                        <a class="btn btn-theme btn-sm" @click="showAddPartModal" id="parts_add" style="float:right; margin-right:5px;" >添加配件</a>

                        <div id="parts_content" style="margin-top:10px; min-height:150px; max-height:300px; overflow-y:scroll; border-radius:5px;background-color:#fbfbfb ">
                            <ul id="parts_ul">

                            </ul>
                        </div>
                    </div>
                </div>
                <div class="row" style="margin:0 auto;  padding-top:5px;">
                    <div class="col-md-6" style="padding-left:0;">
                        <label>附件列表</label>
                        <a class="btn btn-theme btn-sm" style="float:right; margin-right:5px;" @click="showAddFileModal">添加附件</a>

                        <div id="parts_content" style="min-height:150px; border-radius:5px;background-color:#fbfbfb ">
                            <ul id="file_ul">

                            </ul>
                        </div>
                    </div>
                    <div class="col-md-6" style="padding-right:0px;">
                        <label>固定资产卡</label>
                        <a class="btn btn-theme btn-sm" id="card_print" style="float:right;">打印资料卡</a>
                        <div id="parts_content" style="min-height:150px;padding-top:5px; margin-top:10px;border-radius:5px;background-color:#fbfbfb ">
                            <table id="print_table" class="table-bordered" style="width:300px;min-height:140px;border:2px solid #000;margin:auto;font-size:10px;">
                                <tr>
                                    <th colspan="4" style="text-align:center">苏州美嘉塑胶有限公司</th>
                                </tr>
                                <tr>
                                    <th colspan="4" style="text-align:center">财产卡</th>
                                </tr>
                                <tr>
                                    <td><label>设施名称</label></td>
                                    <td id="asssets_fdname"></td>
                                    <td><label>财产编号</label></td>
                                    <td id="assets_code"></td>
                                </tr>
                                <tr>
                                    <td><label>进厂日期</label></td>
                                    <td id="assets_indate"></td>
                                    <td><label>使用部门</label></td>
                                    <td id="assets_usedept"></td>
                                </tr>
                                <tr>
                                    <td><label>盘点日期</label></td>
                                    <td></td>
                                    <td><label>使用保管人</label></td>
                                    <td id="useusername"></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="modal fade" id="log_add_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="exampleModalLabel">添加变更信息</h4>
                            </div>
                            <div class="modal-body">
                                <form>
                                    <div class="form-group">
                                        <label class="control-label">变更信息</label>
                                        <textarea id="add_log_notes" type="text" class="form-control"></textarea>
                                    </div>

                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-primary" id="log_add_submit">提交</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal fade" id="parts_add_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="exampleModalLabel">添加配件</h4>
                            </div>
                            <div class="modal-body">
                                <form>
                                    <div class="form-group">
                                        <label class="control-label">配件名称</label>
                                        <input id="add_parts_name" type="text" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label">配件编号</label>
                                        <input id="add_parts_barcode" type="text" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label">配件型号</label>
                                        <input id="add_parts_model" type="text" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label">配件价格</label>
                                        <input id="add_parts_value" type="text" class="form-control">
                                    </div>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-primary" @click="addPart" id="parts_add_submit">提交</button>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal fade" id="file_add_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="exampleModalLabel">添加附件</h4>
                            </div>
                            <div class="modal-body">
                                <form>
                                    <div class="form-group">
                                        <label class="control-label">附件名称</label>
                                        <input id="file_add_fdname" type="text" class="form-control">
                                    </div>
                                    <div>
                                        <label for="fileUpload">
                                                选择文件
                                            </label>
                                        <br/>
                                        <input id="fileUpload" type="file" multiple="multiple" />
                                        <br />
                                        <!-- <input id="btnUploadFile" type="button" value="上传文件" /> -->
                                    </div>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-primary" @click="addFile" id="btnUploadFile">提交</button>
                            </div>
                        </div>
                    </div>
                </div>


                <div class="modal fade" id="parts_modify_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="exampleModalLabel">编辑配件</h4>
                            </div>
                            <div class="modal-body">
                                <form>
                                    <div class="form-group">
                                        <label class="control-label">配件名称</label>
                                        <input id="modify_parts_name" type="text" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label">配件编号</label>
                                        <input id="modify_parts_barcode" type="text" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label">配件型号</label>
                                        <input id="modify_parts_model" type="text" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label">配件价格</label>
                                        <input id="modify_parts_value" type="text" class="form-control">
                                    </div>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-primary" @click="modifyPart" id="parts_modify_submit ">提交</button>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal fade " id="gdzc_drop_modal ">
                    <div class="modal-dialog ">
                        <div class="modal-content ">
                            <div class="modal-header ">
                                <button type="button " class="close " data-dismiss="modal " aria-label="Close
                                    "><span aria-hidden="true ">&times;</span></button>
                                <h4 class="modal-title ">删除资产</h4>
                            </div>
                            <div class="modal-body ">
                                <p>您真的要删除此项资产吗？</p>
                            </div>
                            <div class="modal-footer ">
                                <button type="button " class="btn btn-default " data-dismiss="modal ">取消</button>
                                <button type="button " class="btn btn-primary " id="gdzc_drop_submit ">确认</button>
                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
            </section>
        </div>
    </div>
</template>
<script>
    import '../assets/js/tableExport.js'
    import '../assets/js/LodopFuncs.js'
    import doc from '../assets/imgs/doc.jpg'
    import pdf from '../assets/imgs/pdf.jpg'
    import ppt from '../assets/imgs/ppt.jpg'
    import rar from '../assets/imgs/rar.jpg'
    import xls from '../assets/imgs/xls.jpg'

    import {
        getLodop
    } from '../assets/js/LodopFuncs.js'
    export default {
        data() {
            return {
                assetsData: '',
                printArray: '',
                currentAssetsId: '',
                ifShowDetail: false,
                currentAssetsDetail: '',
                currentPurchaseDetailId: '',
                currentPurchaseDetail: ''
            }
        },
        methods: {
            back() {

                this.currentAssetsId = ''

            },
            getAllAssets() {
                var _this = this
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/fetchlist2',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'extra.selectfield': '*',
                        'extra.sortfield': 'fidno',
                        'extra.pagesize': 99999999,
                        'extra.pageindex': 1,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        _this.assetsData = retdata.Table2

                    }
                });
            },
            getAssetsTable() {

                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/dept/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_dept = retdata;
                        var cont = '';
                        for (var i = 0; i < info_dept.Table2.length; i++) {
                            cont += '<option value="' + info_dept.Table2[i].fidno + '">' + info_dept.Table2[i].fdname + '</option>';
                        }
                        $('#fsavedeptid,#fusedeptid').html(cont);
                    }
                });
                var _this = this
                var operateEvents = {
                    'click a[name="detail"]': function(e, value, row, index) {
                        _this.currentAssetsId = row.fidno
                        _this.ifShowDetail = true
                        _this.showAssetsDetail()
                    }
                }
                $('#gdzcTable').bootstrapTable('destroy')
                $('#gdzcTable').bootstrapTable({
                    columns: [{
                        checkbox: true
                    }, {
                        field: 'fidno',
                        title: '编号',
                        halign: 'center'
                    }, {
                        field: 'fname',
                        title: '资产名称',
                        halign: 'center',
                    }, {
                        field: 'fbarcode',
                        title: '资产编码',
                        halign: 'center'
                    }, {
                        field: 'ftype',
                        title: '类型',
                        halign: 'center'
                    }, {
                        field: 'fmodel',
                        title: '型号',
                        halign: 'center'
                    }, {
                        field: 'funitid',
                        title: '单位',
                        halign: 'center'
                    }, {
                        field: 'fvalue',
                        title: '价值',
                        halign: 'center'
                    }, {
                        field: 'savefdname',
                        title: '保管部门',
                        halign: 'center'
                    }, {
                        field: 'saveusername',
                        title: '保管人',
                        halign: 'center'
                    }, {
                        field: 'fstatus',
                        title: '状态',
                        halign: 'center'
                    }, {
                        field: "operate",
                        title: '操作',
                        halign: 'center',
                        formatter: '<a class="btn btn-theme btn-xs" name="detail">点击查看详情</a>',
                        events: operateEvents
                    }],
                    data: _this.assetsData,
                    pagination: true,
                    paginationLoop: true,
                    onlyInfoPagination: false,
                    striped: true,
                    sidePagination: 'client',
                    pageNumber: 1,
                    pageSize: 10,
                    pageList: [10, 25, 50, 100, 200, 500],
                    smartDisplay: true,
                    selectItemName: 'gdzc',
                    showHeader: true,
                    maintainSelected: true,
                    clickToSelect: true,
                    singleSelect: false,
                    checkboxHeader: true,
                })
            },
            getDept() {
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/dept/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_dept = retdata;
                        var cont = '<option value="0">全部</option>';
                        for (var i = 0; i < info_dept.Table2.length; i++) {
                            cont += '<option value="' + info_dept.Table2[i].fidno + '">' + info_dept.Table2[i].fdname + '</option>';
                        }
                        $('#assets_search_dept').html(cont);
                    }
                });
            },
            getAssetsByCondition() {
                var _this = this
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/fetchlistbycondition',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'ftype': $('#assets_search_ftype').val(),
                        'fsavedeptid': $('#assets_search_dept').val(),
                        'fname': $('#extra').val()
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        _this.assetsData = retdata.Table2
                    }
                });
            },
            postToExcel() {
                $('#gdzcTable').tableExport({
                    separator: ',',
                    ignoreColumn: [6, 6],
                    tableName: 'yourTableName',
                    type: 'excel',
                    pdfFontSize: 14,
                    pdfLeftMargin: 20,
                    escape: 'true',
                    htmlContent: 'true',
                    consoleLog: 'false',
                });
            },
            padleft0(obj) {
                return obj.toString().replace(/^[0-9]{1}$/, "0" + obj);
            },
            getnowtime() {
                var nowtime = new Date();
                var year = nowtime.getFullYear();
                var month = this.padleft0(nowtime.getMonth() + 1);
                var day = this.padleft0(nowtime.getDate());
                var hour = this.padleft0(nowtime.getHours());
                var minute = this.padleft0(nowtime.getMinutes());
                var second = this.padleft0(nowtime.getSeconds());
                var millisecond = nowtime.getMilliseconds();
                millisecond = millisecond.toString().length == 1 ? "00" + millisecond : millisecond.toString().length == 2 ? "0" + millisecond : millisecond;
                return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second + "." + millisecond;
            },
            showPrintMOdal() {
                this.printArray = $('input:checkbox[name="gdzc"]:checked').map(function(index, elem) {
                    return $(elem).parent().next().text()
                }).get()
                if (this.printArray == '') {
                    this.$store.commit('showModal','先选择要打印的项')
                } else {
                    $('#print_submit_modal').modal('show');
                }
            },
            printCards() {
                var _this = this
                $('#print_submit_modal').modal('hide');
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/fetchlist2',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'extra.selectfield': '*',
                        'extra.sortfield': 'fidno',
                        'extra.pagesize': 9999999,
                        'extra.pageindex': 1,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var pddate = _this.getnowtime();
                        if (localStorage.activeteamid != '16') {
                            var company = '苏州美嘉塑胶有限公司'
                        } else {
                            var company = '苏州美冠塑胶有限公司'
                        }
                        for (var i = 0; i < retdata.Table2.length; i++) {
                            for (var j = 0; j < _this.printArray.length; j++) {
                                if (retdata.Table2[i].fidno == _this.printArray[j]) {
                                    if (retdata.Table2[i].findate.substring(0, 4) == '1970') {
                                        retdata.Table2[i].findate = '-'
                                    }
                                    var LODOP = getLodop();
                                    LODOP.PRINT_INITA(6, 7, 863, 524, retdata.Table2[i].fbarcode + i);
                                    LODOP.ADD_PRINT_RECT(15, 7, 310, 146, 0, 1);
                                    LODOP.ADD_PRINT_RECT(15, 7, 310, 30, 0, 1);
                                    LODOP.ADD_PRINT_RECT(44, 7, 310, 30, 0, 1);
                                    LODOP.ADD_PRINT_RECT(73, 7, 157, 30, 0, 1);
                                    LODOP.ADD_PRINT_RECT(73, 163, 154, 30, 0, 1);
                                    LODOP.ADD_PRINT_RECT(102, 7, 157, 30, 0, 1);
                                    LODOP.ADD_PRINT_RECT(102, 163, 154, 30, 0, 1);
                                    LODOP.ADD_PRINT_RECT(131, 7, 157, 30, 0, 1);
                                    LODOP.ADD_PRINT_RECT(131, 163, 154, 30, 0, 1);
                                    LODOP.ADD_PRINT_TEXT(21, 43, 245, 20, company);
                                    LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
                                    LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                    LODOP.ADD_PRINT_TEXT(51, 117, 95, 20, "财产卡");
                                    LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
                                    LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                    LODOP.ADD_PRINT_LINE(103, 65, 73, 66, 0, 1);
                                    LODOP.ADD_PRINT_LINE(101, 65, 131, 66, 0, 1);
                                    LODOP.ADD_PRINT_LINE(131, 65, 161, 66, 0, 1);
                                    LODOP.ADD_PRINT_LINE(103, 220, 73, 221, 0, 1);
                                    LODOP.ADD_PRINT_LINE(131, 220, 101, 221, 0, 1);
                                    LODOP.ADD_PRINT_LINE(160, 220, 130, 221, 0, 1);
                                    LODOP.ADD_PRINT_TEXT(83, 11, 60, 20, "设施名称");
                                    LODOP.ADD_PRINT_TEXT(83, 169, 60, 20, "财产编号");
                                    LODOP.ADD_PRINT_TEXT(112, 11, 60, 20, "进厂日期");
                                    LODOP.ADD_PRINT_TEXT(112, 168, 60, 20, "使用部门");
                                    LODOP.ADD_PRINT_TEXT(141, 11, 60, 20, "盘点日期");
                                    LODOP.ADD_PRINT_TEXT(141, 176, 55, 20, "使用人");
                                    LODOP.ADD_PRINT_TEXT(83, 66, 98, 20, retdata.Table2[i].fname);
                                    LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                    LODOP.ADD_PRINT_TEXT(112, 66, 98, 20, retdata.Table2[i].findate.substring(0, 10));
                                    LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                    LODOP.ADD_PRINT_TEXT(83, 221, 95, 20, retdata.Table2[i].fbarcode);
                                    LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                    LODOP.ADD_PRINT_TEXT(112, 220, 97, 20, retdata.Table2[i].usefdname);
                                    LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                    LODOP.ADD_PRINT_TEXT(141, 66, 98, 20, pddate.substring(0, 10));
                                    LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                    LODOP.ADD_PRINT_TEXT(141, 219, 98, 20, retdata.Table2[i].useusername);
                                    LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                    LODOP.SET_PRINT_PAGESIZE(0, 900, 500, "a");
                                    //宽90，高55，纵向（打印机设置）
                                    LODOP.NewPage();
                                    // LODOP.PREVIEW();
                                    LODOP.PRINT();
                                }
                            }
                        }
                    }
                });
            },
            watcher() {
                if (this.currentAssetsId == '') {
                    this.ifShowDetail = false
                    this.getAssetsTable()
                } else {
                    this.ifShowDetail = true
                }
            },
            showAssetsDetail() {
                var _this = this
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/files/fetchlistbyfdid',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fteamid': localStorage.activeteamid,
                        'fdid': _this.currentAssetsId
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        if (retdata.Table1[0].status == true) {

                            var htmlcont = "";
                            for (var i = 0; i < retdata.Table2.length; i++) {
                                var filepath = retdata.Table2[i].flocation;
                                filepath = filepath.substring(27);
                                var filetype = retdata.Table2[i].flocation.split('.')[1];
                                if (filetype == 'jpg' || filetype == 'png' || filetype == 'jpeg' || filetype == 'gif') {
                                    htmlcont += '<li style="float:left; list-style:none;padding:5px;"><div><a href="' + filepath + '"><img src="' + filepath + '" style="height:40px;width:35px;"><br/><span>' + retdata.Table2[i].fdname + '</span></a></div></li>'
                                } else if (filetype == 'doc' || filetype == 'docx') {
                                    htmlcont += '<li style="float:left; list-style:none;padding:5px;"><div><a href="' + filepath + '"><img src="' + doc + '" style="height:40px;width:35px;"><br/><span>' + retdata.Table2[i].fdname + '</span></a></div></li>'
                                } else if (filetype == 'xls' || filetype == 'xlsx') {
                                    htmlcont += '<li style="float:left; list-style:none;padding:5px;"><div ><a href="' + filepath + '"><img src="' + xls + '" style="height:40px;width:35px;"><br/><span>' + retdata.Table2[i].fdname + '</span></a></div></li>'
                                } else if (filetype == 'ppt' || filetype == 'pptx') {
                                    htmlcont += '<li style="float:left; list-style:none;padding:5px;"><div ><a href="' + filepath + '"><img src="' + ppt + '" style="height:40px;width:35px;"><br/><span>' + retdata.Table2[i].fdname + '</span></a></div></li>'
                                } else if (filetype == 'rar' || filetype == 'zip') {
                                    htmlcont += '<li style="float:left; list-style:none;padding:5px;"><div ><a href="' + filepath + '"><img src="' + rar + '" style="height:40px;width:35px;"><br/><span>' + retdata.Table2[i].fdname + '</span></a></div></li>'
                                } else {
                                    htmlcont += '<li style="float:left; list-style:none;padding:5px;"><div ><a href="' + filepath + '"><img src="' + pdf + '" style="height:40px;width:35px;"><br/><span>' + retdata.Table2[i].fdname + '</span></a></div></li>'
                                }
                            }
                            $('#file_ul').html(htmlcont);
                        }
                    }
                });
                //获取变更信息
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets_log/fetchassets_logbyfdid',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fteamid': localStorage.activeteamid,
                        'fdid': _this.currentAssetsId
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var htmlcont = "";
                        if (retdata.Table1[0].status == true) {
                            for (var i = 0; i < retdata.Table2.length; i++) {
                                htmlcont += '<tr><td>' + parseInt(i + 1) + '</td><td>' + retdata.Table2[i].fnotes + '</td><td>' + retdata.Table2[i].username + '</td><td>' + retdata.Table2[i].fentdate.substring(0, 10) + '</td></tr>';
                            }
                        }
                        $('#assets_log tbody').html(htmlcont);
                    }
                });
                //获取单位名称
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/unit/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,

                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_unit = retdata;
                        var cont = '';
                        for (var i = 0; i < info_unit.Table2.length; i++) {
                            cont += '<option value="' + info_unit.Table2[i].fcname + '">' + info_unit.Table2[i].fcname + '</option>';
                        }
                        $('#funitid').html(cont);
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/whlocation/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var cont = '';
                        for (var i = 0; i < retdata.Table2.length; i++) {
                            if (retdata.Table2[i].fdid == 0) {

                                cont += '<option name="whlocation" value="' + retdata.Table2[i].fidno + '">' + retdata.Table2[i].fname + '</option>';
                            }
                        }
                        $('#fwh').html(cont);
                    }
                });
                //获取所有库位

                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/whlocation/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var cont = '';
                        for (var i = 0; i < retdata.Table2.length; i++) {
                            if (retdata.Table2[i].fdid != 0) {

                                cont += '<option name="whlocation" value="' + retdata.Table2[i].fidno + '">' + retdata.Table2[i].fname + '</option>';
                            }
                        }
                        $('#flocation').html(cont);
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/user/fetchteamuser',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'teamid': localStorage.activeteamid
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_user = retdata;
                        var cont = '';
                        for (var i = 0; i < info_user.Table2.length; i++) {
                            cont += '<option value="' + info_user.Table2[i].fuserid + '">' + info_user.Table2[i].username + '</option>';
                        }
                        $('#fsaveuserid,#fuseuserid').html(cont);
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/cs/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    async: true,
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_cs = retdata;
                        var cont = '';
                        for (var i = 0; i < info_cs.Table2.length; i++) {
                            cont = cont + '<option value="' + info_cs.Table2[i].fidno + '">' + info_cs.Table2[i].fullname + '</option>'
                        }
                        $('#fsupplierid,#fmanuid').html(cont);
                    }
                });




                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fparentidno': _this.currentAssetsId
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var j = 0;
                        parent = [];
                        var htmlcont = '';
                        for (var i = 0; i < retdata.Table2.length; i++) {
                            if (retdata.Table2[i].fparentidno == _this.currentAssetsId) {
                                htmlcont += '<li style="float:left; text-align:left; clear:both; list-style:none; " id="' + retdata.Table2[i].fidno + '"><div style="width:260px;"><input type="radio" name="parts"><span>编码:' + retdata.Table2[i].fname + '</span><span style="padding-left:20px;">名称:' + retdata.Table2[i].fbarcode + '</span></input></div><ul></ul></li>';

                                parent[j] = retdata.Table2[i].fidno;
                                j++;
                            }
                        }
                        $('#parts_ul').html(htmlcont);

                        for (var i = 0; i < retdata.Table2.length; i++) {
                            for (var x = 0; x < j; x++) {
                                if (retdata.Table2[i].fparentidno == parent[x]) {

                                    $('li').each(function() {
                                        if ($(this).attr('id') == parent[x]) {

                                            $(this).children('ul').append('<li style="list-style:none; " id="' + retdata.Table2[i].fidno + '"><div style="width:260px;"><input type="radio" name="parts"><span>编码:' + retdata.Table2[i].fname + '</span><span style="padding-left:20px;">名称:' + retdata.Table2[i].fbarcode + '</span></div><ul></ul></li>');
                                        }
                                    });
                                    parent[j++] = retdata.Table2[i].fidno;
                                }
                            }
                        }
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/fetchlistbyid',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fidno': _this.currentAssetsId
                    },
                    dataType: 'json',
                    async: true,
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        if (retdata.Table2[0].fyn1 == '未验收') {
                            retdata.Table2[0].fyndate1 = ''
                        }
                        $('#fparentidno').val(retdata.Table2[0].fparentidno);
                        $('#fbarcode').val(retdata.Table2[0].fbarcode);
                        $('#ftype').val(retdata.Table2[0].ftype);
                        $('#fname').val(retdata.Table2[0].fname);
                        $('#fmodel').val(retdata.Table2[0].fmodel);
                        $('#funitid').val(retdata.Table2[0].funitid);
                        $('#fvalue').val(retdata.Table2[0].fvalue);
                        $('#fsavedeptid').val(retdata.Table2[0].fsavedeptid);
                        $('#fsaveuserid').val(retdata.Table2[0].fsaveuserid);
                        $('#fusedeptid').val(retdata.Table2[0].fusedeptid);
                        $('#fuseuserid').val(retdata.Table2[0].fuseuserid);
                        $('#fwh').val(retdata.Table2[0].fwh);
                        $('#flocation').val(retdata.Table2[0].flocation)
                        $('#finway').val(retdata.Table2[0].finway);
                        $('#findate').val(retdata.Table2[0].findate.substring(0, 10));
                        $('#fsupplierid').val(retdata.Table2[0].fsupplierid);
                        $('#fmanuid').val(retdata.Table2[0].fmanuid);
                        $('#fmanudate').val(retdata.Table2[0].fmanudate.substring(0, 10));
                        $('#fusemonths').val(retdata.Table2[0].fusemonths);
                        $('#fnotes').val(retdata.Table2[0].fnotes);
                        $('#fstatus').val(retdata.Table2[0].fstatus);
                        $('#fyn1').val(retdata.Table2[0].fyn1);
                        $('#fynuser1').val(retdata.Table2[0].fynusername1);
                        $('#fyndate1').val(retdata.Table2[0].fyndate1);
                        $('#fyn2').val(retdata.Table2[0].fyn2);
                        $('#fynuser2').val(retdata.Table2[0].fynuser2);
                        $('#fyndate2').val(retdata.Table2[0].fyndate2);
                        $('#invoice').val(retdata.Table2[0].invoice);
                        //放入固定资产卡中
                        $('#asssets_fdname').text(retdata.Table2[0].fname);
                        $('#assets_code').text(retdata.Table2[0].fbarcode);
                        $('#assets_indate').text(retdata.Table2[0].findate.substring(0, 10));
                        $('#assets_usedept').text(retdata.Table2[0].usefdname);
                        $('#useusername').text(retdata.Table2[0].useusername);
                    }
                });
            },
            getWh() {
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/whlocation/fetchallListbyfdid',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fdid': $('#fwh').val(),
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {

                        var cont = '';
                        for (var i = 0; i < retdata.Table2.length; i++) {
                            cont += '<option name="whlocate" value="' + retdata.Table2[i].fidno + '">' + retdata.Table2[i].fname + '</option>';
                        }
                        $('#flocation').html(cont);
                    }
                });
            },
            getQgwrkTable() {
                var _this = this
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/purchasedetail/fetchmypurchasedetails',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'extra.selectfield': '*',
                        'extra.sortfield': 'fidno',
                        'extra.pagesize': 9999999,
                        'extra.pageindex': 1,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var operateEvents = {
                            'click a[name="qgwrk"]': function(elem, value, row, index) {
                                _this.ruKu()
                                _this.currentPurchaseDetailId = row.fidno
                            }
                        }
                        $('#qgwrkTable').bootstrapTable('destroy')
                        $('#qgwrkTable').bootstrapTable({
                            columns: [{
                                field: 'fitemno',
                                title: '物料编码',
                                halign: 'center'
                            }, {
                                field: 'fcgn',
                                title: '物料名称',
                                halign: 'center'
                            }, {
                                field: 'fmodel',
                                title: '型号',
                                halign: 'center'
                            }, {
                                field: 'fprice',
                                title: '价格',
                                halign: 'center'
                            }, {
                                field: 'operate',
                                title: '操作',
                                halign: "center",
                                formatter: '<a class="btn btn-success btn-sm" name="qgwrk">入库</a>',
                                events: operateEvents
                            }],
                            data: retdata.Table2,
                            pagination: true,
                            paginationLoop: true,
                            onlyInfoPagination: false,
                            striped: true,
                            sidePagination: 'client',
                            pageNumber: 1,
                            pageSize: 10,
                            pageList: [10, 25, 50, 100, 200, 500],
                            smartDisplay: true,
                            // selectItemName: 'gdzc',
                            showHeader: true,
                            maintainSelected: true,
                            clickToSelect: true,
                            singleSelect: false,
                            checkboxHeader: true,
                        })
                    }
                });
            },
            ruKu() {
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/dept/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_dept = retdata;
                        var cont = '';
                        for (var i = 0; i < info_dept.Table2.length; i++) {
                            cont += '<option value="' + info_dept.Table2[i].fidno + '">' + info_dept.Table2[i].fdname + '</option>';
                        }
                        $('#fmsavedeptid,#fmusedeptid').html(cont);
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/unit/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,

                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_unit = retdata;
                        var cont = '';
                        for (var i = 0; i < info_unit.Table2.length; i++) {
                            cont += '<option value="' + info_unit.Table2[i].fcname + '">' + info_unit.Table2[i].fcname + '</option>';
                        }
                        $('#fmunitid').html(cont);
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/whlocation/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var cont = '';
                        for (var i = 0; i < retdata.Table2.length; i++) {
                            if (retdata.Table2[i].fdid == 0) {

                                cont += '<option name="whlocation" value="' + retdata.Table2[i].fidno + '">' + retdata.Table2[i].fname + '</option>';
                            }
                        }
                        $('#fmwh').html(cont);
                    }
                });
                //获取所有库位

                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/whlocation/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var cont = '';
                        for (var i = 0; i < retdata.Table2.length; i++) {
                            if (retdata.Table2[i].fdid != 0) {

                                cont += '<option name="whlocation" value="' + retdata.Table2[i].fidno + '">' + retdata.Table2[i].fname + '</option>';
                            }
                        }
                        $('#fmlocation').html(cont);
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/user/fetchteamuser',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'teamid': localStorage.activeteamid
                    },
                    dataType: 'json',
                    crossDomain: true,
                    async: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_user = retdata;
                        var cont = '';
                        for (var i = 0; i < info_user.Table2.length; i++) {
                            cont += '<option value="' + info_user.Table2[i].fuserid + '">' + info_user.Table2[i].username + '</option>';
                        }
                        $('#fmsaveuserid,#fmuseuserid').html(cont);
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/cs/fetchalllist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                    },
                    dataType: 'json',
                    async: true,
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        var info_cs = retdata;
                        var cont = '';
                        for (var i = 0; i < info_cs.Table2.length; i++) {
                            cont = cont + '<option value="' + info_cs.Table2[i].fidno + '">' + info_cs.Table2[i].fullname + '</option>'
                        }
                        $('#fmsupplierid,#fmmanuid').html(cont);
                    }
                });
                $('#gdzc_add_modal').modal('show')
            },
            addSubmit() {
                var _this = this
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/add',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fparentidno': '0',
                        'fbarcode': $('#fmbarcode').val(),
                        'ftype': $('#fmtype').val(),
                        'fname': $('#fmname').val(),
                        'fmodel': $('#fmmodel').val(),
                        'funitid': $('#fmunitid').val(),
                        'fvalue': $('#fmvalue').val(),
                        'fsavedeptid': $('#fmsavedeptid').val(),
                        'fsaveuserid': $('#fmsaveuserid').val(),
                        'fusedeptid': $('#fmusedeptid').val(),
                        'fuseuserid': $('#fmuseuserid').val(),
                        'fwh': $('#fmwh').val(),
                        'flocation': $('#fmlocation').val(),
                        'finway': $('#fminway').val(),
                        'findate': $('#fmindate').val(),
                        'fsupplierid': $('#fmsupplierid').val(),
                        'fmanuid': $('#fmmanuid').val(),
                        'fmanudate': $('#fmmanudate').val(),
                        'fusemonths': $('#fmusemonths').val(),
                        'fnotes': $('#fmnotes').val(),
                        'fstatus': '在用',
                        'fyn1': '未验收',
                        'invoice': $('#minvoice').val()
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        $('#gdzc_add_modal').modal('hide');
                    }
                });
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/purchasedetail/fetchlistbyid',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fteamid': localStorage.activeteamid,
                        'fidno': _this.currentPurchaseDetailId
                    },
                    dataType: 'json',
                    async: false,
                    crossDomain: true,
                    error: function(request) {
                        //_this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        _this.currentPurchaseDetail = retdata;
                    }
                });
                var mydate = _this.getnowtime();
                mydate = _this.padleft0(mydate);

                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/purchasedetail/update',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fteamid': localStorage.activeteamid,
                        'fidno': _this.currentPurchaseDetailId,
                        'fidno2': _this.currentPurchaseDetail.Table2[0].fidno2,
                        'fitemidno': _this.currentPurchaseDetail.Table2[0].fitemidno,
                        'fqty': _this.currentPurchaseDetail.Table2[0].fqty,
                        'fprice': _this.currentPurchaseDetail.Table2[0].fprice,
                        'fsum': _this.currentPurchaseDetail.Table2[0].fsum,
                        'fnotes': _this.currentPurchaseDetail.Table2[0].fnotes,
                        'fpurchaseuser': _this.currentPurchaseDetail.Table2[0].fpurchaseuser,
                        'fyn1': _this.currentPurchaseDetail.Table2[0].fyn1,
                        'fynuser1': _this.currentPurchaseDetail.Table2[0].fynuser1,
                        'fyndate1': _this.currentPurchaseDetail.Table2[0].fyndate1,
                        'fnote1': _this.currentPurchaseDetail.Table2[0].fnote1,
                        'fyn2': _this.currentPurchaseDetail.Table2[0].fyn1,
                        'fynuser2': _this.currentPurchaseDetail.Table2[0].fyn1,
                        'fyndate2': _this.currentPurchaseDetail.Table2[0].fyndate2,
                        'fnote2': _this.currentPurchaseDetail.Table2[0].fnote2,
                        'fyn3': '已入库',
                        'fyndate3': mydate,
                    },
                    dataType: 'json',
                    async: false,
                    crossDomain: true,
                    error: function(request) {},
                    success: function(retdata) {
                        _this.getQgwrkTable()
                    }
                });
            },
            getRkwclTable() {
                var _this = this
                var urlLists = []
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/security/fetchuserfunctionlist',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'teamid': localStorage.activeteamid,
                    },
                    async: false,
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        for (var i = 0; i < retdata.Table2.length; i++) {
                            urlLists.push(retdata.Table2[i].functionname)
                        }
                    }
                });
                var flage = urlLists.indexOf('rkwys')
                if (flage != -1) {
                    $.ajax({
                        type: 'POST',
                        url: 'http://192.168.1.66:808/api/assets/fetchinnotcommit',
                        data: {
                            'token': localStorage.token,
                            'userid': localStorage.userid
                        },
                        dataType: 'json',
                        crossDomain: true,
                        error: function(request) {
                            _this.$store.commit('showModal','连接错误')
                        },
                        success: function(retdata) {
                            var tableData
                            if (retdata.Table1[0].fstatus == false) {
                                tableData = ''
                            } else {
                                tableData = retdata.Table2
                            }
                            var operateEvents = {
                                'click a[name="seeDetail"]': function(elem, value, row, index) {
                                    _this.currentAssetsId = row.fidno
                                    _this.ifShowDetail = true
                                    _this.showAssetsDetail()
                                },
                                'click a[name="yanshou"]': function(elem, value, row, index) {
                                    $.ajax({
                                        type: 'POST',
                                        url: 'http://192.168.1.66:808/api/assets/passcheck',
                                        data: {
                                            'token': localStorage.token,
                                            'userid': localStorage.userid,
                                            'fidno': row.fidno,
                                            'fyn1': '已验收',
                                        },
                                        dataType: 'json',
                                        crossDomain: true,
                                        error: function() {
                                            _this.$store.commit('showModal','连接错误')
                                        },
                                        success: function(retdata) {
                                            _this.getRkwclTable()
                                        }
                                    });
                                }
                            }
                            $('#rkwysTable').bootstrapTable('destroy')
                            $('#rkwysTable').bootstrapTable({
                                columns: [{
                                    field: 'fidno',
                                    title: '资产编号',
                                    halign: 'center'
                                }, {
                                    field: 'fbarcode',
                                    title: '物料编码',
                                    halign: 'center'
                                }, {
                                    field: 'ftype',
                                    title: '类型',
                                    halign: 'center'
                                }, {
                                    field: 'fname',
                                    title: '物料名称',
                                    halign: 'center'
                                }, {
                                    field: 'fmodel',
                                    title: '型号',
                                    halign: 'center'
                                }, {
                                    field: 'funitid',
                                    title: '单位',
                                    halign: 'center'
                                }, {
                                    field: 'fvalue',
                                    title: '价格',
                                    halign: 'center'
                                }, {
                                    field: 'savefdname',
                                    title: '保管部门',
                                    halign: 'center'
                                }, {
                                    field: 'saveusername',
                                    title: '保管人',
                                    halign: 'center'
                                }, {
                                    field: 'fstatus',
                                    title: '状态',
                                    halign: 'center'
                                }, {
                                    field: 'operate',
                                    title: '操作',
                                    halign: "center",
                                    formatter: '<a class="btn btn-theme btn-sm" name="seeDetail">详情</a> <a class="btn btn-success btn-sm" name="yanshou">验收通过</a>',
                                    events: operateEvents
                                }],
                                data: tableData,
                                pagination: true,
                                paginationLoop: true,
                                onlyInfoPagination: false,
                                striped: true,
                                sidePagination: 'client',
                                pageNumber: 1,
                                pageSize: 10,
                                pageList: [10, 25, 50, 100, 200, 500],
                                smartDisplay: true,
                                // selectItemName: '',
                                showHeader: true,
                                maintainSelected: true,
                                clickToSelect: true,
                                singleSelect: false,
                                checkboxHeader: true,
                            })
                        }
                    });
                } else {
                    _this.$store.commit('showModal','无权限')
                }
            },
            showAddFileModal() {
                $('#file_add_modal').modal('show')
            },
            addFile() {
                var _this = this
                var data = new FormData();
                var files = $("#fileUpload").get(0).files;
                if (files.length > 0) {
                    for (var i = 0; i < files.length; i++) {
                        data.append(i.toString(), files[i]);
                    }
                    data.append('token', localStorage.token);
                    data.append('userid', localStorage.userid);
                }

                $.ajax({
                    type: "post",
                    url: "http://192.168.1.66:808/api/upload/upload",
                    contentType: false,
                    cache: false,
                    currentType: false,
                    processData: false,
                    data: data,
                    success: function(res) {
                        var info_filepath = res.Table1[0].message;
                        $('#file_add_modal').modal('hide');
                        $.ajax({
                            type: 'POST',
                            url: 'http://192.168.1.66:808/api/files/add',
                            data: {
                                'token': localStorage.token,
                                'userid': localStorage.userid,
                                'fdid': _this.currentAssetsId,
                                'fdname': $('#file_add_fdname').val(),
                                'flocation': info_filepath,
                                'fteamid': localStorage.activeteamid
                            },
                            dataType: 'json',
                            crossDomain: true,
                            // error: function (request) {

                            // },
                            success: function(retdata) {
                                _this.showAssetsDetail()
                            }
                        });
                    }
                });
            },
            showAddPartModal() {
                $('#parts_add_modal').modal('show')
            },
            addPart() {
                var _this = this
                var id = $('input:radio[name="parts"]:checked').parent().parent().attr('id')
                if (id == undefined) {
                    id = this.currentAssetsId
                }
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/add',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fparentidno': id,
                        'fbarcode': $('#add_parts_barcode').val(),
                        'fname': $('#add_parts_name').val(),
                        'fmodel': $('#add_parts_model').val(),
                        'fvalue': $('#add_parts_value').val(),
                        'ftype': $('#ftype').val(),
                        'funitid': $('#funitid').val(),
                        'fdeptid': $('#fdeptid').val(),
                        'fuserid': $('#fuserid').val(),
                        'fwh': $('#fwh').val(),
                        'flocation': $('#flocation').val(),
                        'finway': $('#finway').val(),
                        'findate': $('#findate').val(),
                        'fsupplierid': $('#fsupplierid').val(),
                        'fmanuid': $('#fmanuid').val(),
                        'fmanudate': $('#fmanudate').val(),
                        'fusemonths': $('#fusemonths').val(),
                        'fnotes': $('#fnotes').val(),
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        $('#parts_add_modal').modal('hide')
                        _this.showAssetsDetail()
                    }
                });
            },
            showModifyPartsModal() {
                var ids = $('input:radio[name="parts"]:checked').parent().parent().attr('id')
                if (ids == undefined) {
                    this.$store.commit('showModal','请先选择要编辑的配件')
                } else {
                    $('#parts_modify_modal ').modal('show')
                }
            },
            modifyPart() {
                var _this = this
                var ids = $('input:radio[name="parts"]:checked').parent().parent().attr('id')
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/update',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fidno': ids,
                        'fbarcode': $('#modify_parts_barcode').val(),
                        'fname': $('#modify_parts_name').val(),
                        'fmodel': $('#modify_parts_model').val(),
                        'fvalue': $('#modify_parts_value').val(),

                        'ftype': $('#ftype').val(),
                        'funitid': $('#funitid').val(),
                        'fdeptid': $('#fdeptid').val(),
                        'fuserid': $('#fuserid').val(),
                        'fwh': $('#fwh').val(),
                        'flocation': $('#flocation').val(),
                        'finway': $('#finway').val(),
                        'findate': $('#findate').val(),
                        'fsupplierid': $('#fsupplierid').val(),
                        'fmanuid': $('#fmanuid').val(),
                        'fmanudate': $('#fmanudate').val(),
                        'fusemonths': $('#fusemonths').val(),
                        'fnotes': $('#fnotes').val(),
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        _this.showAssetsDetail()
                    }
                });
            },
            deleteParts() {
                var _this = this
                var ids = $('input:radio[name="parts"]:checked').parent().parent().attr('id')
                $.ajax({
                    type: 'POST',
                    url: 'http://192.168.1.66:808/api/assets/delete',
                    data: {
                        'token': localStorage.token,
                        'userid': localStorage.userid,
                        'fidno': ids,
                    },
                    dataType: 'json',
                    crossDomain: true,
                    error: function(request) {
                        _this.$store.commit('showModal','连接错误')
                    },
                    success: function(retdata) {
                        _this.showAssetsDetail()
                    }
                });
            },
            gdzcAdd() {
                $('#gdzc_add_modal').modal('show')
            }
        },
        mounted() {
            this.getDept()
            this.getAllAssets()
            this.getQgwrkTable()

        },
        watch: {
            assetsData: 'getAssetsTable',
            currentAssetsId: 'watcher'
        }
    }
</script>
<style>

</style>